#-------------------------------------------------------------------------------
# Name:        module2
# Purpose:
#
# Author:      Student
#
# Created:     03/07/2012
# Copyright:   (c) Student 2012
# Licence:     <your licence>
#-------------------------------------------------------------------------------
import random
Word_List=[]
f= open ("C:/Users/Student/Desktop/html/words.txt", "r")
for x in f:
    x=x.replace('\n','')
    Word_List.append(x)

def main():
    enterWord = random.choice(Word_List)
    Words_Correct=[]
    print("The length of the Word is "+str(len(enterWord))+" letters")
    z=0
    Number_Letters=[]
    Letter_Used=[]
    current=""
    while (z<len(enterWord)):
        current=current+ "_"
        z=z+1

    print(current)
    Hangman_Word=list(enterWord)
    x=5
    l=len(Hangman_Word)

    counter=0

    while(x>0 and l>0):
        enterLetter=input("Please Enter the Letter you Wish to guess")
        Letter_Used.append(enterLetter)
        if(enterLetter in Hangman_Word):
            print("Good Job!! You got a Letter ")
            for c in Hangman_Word:
                #Number_Letters.insert(counter, c)
                if(c==enterLetter):
                    del(Hangman_Word[counter])
                    l=l-1
                counter=counter+1
        else:
            print("That letter is not in the Word. You lose a life")
            x=x-1
        print("You have "+str(x)+" guesses left")

        current_in=""
        ctr=0
        for i in list(enterWord):
            if enterLetter==i:
                current_in+=enterLetter
            else:
                current_in+=current[ctr]
            ctr=ctr+1
        current=current_in
        print("Current Progress on Word: ")
        print(current)

        counter=0
        print("The Hangman:")
        if x < 5: print ('   O   ')
        if x < 4: print (' \_|_/ ')
        if x < 3: print ('   |   ')
        if x < 2: print ('  / \  ')
        if x < 1: print (' d   b ')

        print("The letter you have used are: ")
        print(Letter_Used)
        #print(Number_Letters)
    if(x==0):
        print("Game over:(")
        print(enterWord)

    if(l==0):
        print("You Won!!!!:)")
        print("The word was "+(enterWord)+"!!")

if __name__ == '__main__':
    main()

